#include "Weibull_distribution.h"
#include <iostream>
#include <QDebug>
#include <random>

Weibull_distribution::Weibull_distribution()
{

}

void Weibull_distribution::get_mean_value()
{
    double weibull_mean = Distribution_parameter_1*tgamma(1+1/(Distribution_parameter_2));
    qDebug() << "weibull_mean is" << weibull_mean;
}

void Weibull_distribution::get_deviation()
{
    double weibull_deviation = pow((Distribution_parameter_1),2)*(tgamma(1+2/(Distribution_parameter_2))-pow(tgamma(1+1/(Distribution_parameter_2)),2));
    qDebug() << "weibull_std is" << weibull_deviation;
}

void Weibull_distribution::get_random_number()
{
    std::default_random_engine generator;                        //分布生成器
    std::weibull_distribution<double> distribution(Distribution_parameter_2, Distribution_parameter_1);

    double SN=Sample_Number;
    double *a;
    a = new double[SN];
    for (int i = 0; i<SN; ++i)              //生成的均匀分布随机数放入a中
    {
        a[i] = distribution(generator);
    }

    std::cout <<"Uniform distribution " <<SN<<" samples is:"<<std::endl;
    for ( int j = 0; j < SN; j++ )           //打印a
        std::cout << a[ j ] <<" ";
//  return 0;

}
